package medOffice.Gui;

import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.List;

import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JSeparator;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;

import medOffice.Consulta;
import medOffice.PlanoDeSaude;
import medOffice.RelatoriosConsultas;

/**
 * This code was edited or generated using CloudGarden's Jigloo
 * SWT/Swing GUI Builder, which is free for non-commercial
 * use. If Jigloo is being used commercially (ie, by a corporation,
 * company or business for any purpose whatever) then you
 * should purchase a license for each developer using Jigloo.
 * Please visit www.cloudgarden.com for details.
 * Use of Jigloo implies acceptance of these licensing terms.
 * A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
 * THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
 * LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
 */
/**
 * Classe GUI para gerar relatórios de lucros
 * 
 * @author Ana Clara Lacerda - anacls@lcc.ufcg.edu.bf
 * @version 0.1 - 02/12/2009
 */
public class RelatoriosGUI {

	private JFrame escolha;
	private JTabbedPane tabbed;
	private JPanel panelEscolha, panelRelatorio;
	private List<PlanoDeSaude> planos;
	private List<Consulta> consultas;
	private JTextField ano2;
	private JTextField ano1;
	private JComboBox dia1, dia2, dia;
	private JRadioButton porPlano;
	private JRadioButton entreDatas;
	private JRadioButton dataEspecifica;
	private ButtonGroup grupoBotoes;
	private JTextField ano;
	private JComboBox planosDeSaude, mes, mes1, mes2;
	private JLabel jLabel11;
	private JLabel jLabel10;
	private JRadioButton todasConsultas;
	private JSeparator jSeparator2;
	private JSeparator jSeparator1;
	private JLabel jLabel4;
	private JLabel jLabel5;
	private JLabel jLabel9;
	private JLabel jLabel8;
	private JLabel jLabel7;
	private JLabel jLabel6;
	private JLabel jLabel3;
	private JLabel jLabel2;
	private JLabel jLabel1;
	private JButton ok;
	private JButton gera;
	private JButton limpa;
	private JTextArea titulo;
	private JTextArea textoRelatorio;
	private Calendar data, dataInicial, dataFinal;
	private PlanoDeSaude planoEscolhido;
	private JTextArea explicacao;
	private JTextArea informacao;
	private JButton close;

	public RelatoriosGUI(List<PlanoDeSaude> planos, List<Consulta> consultas, JTabbedPane tabbed) {
		this.consultas = consultas;
		this.planos = planos;
		this.tabbed = tabbed;
	}

	public void escolheRelatorio() {
		{
			panelEscolha = new JPanel();
			GroupLayout panelLayout = new GroupLayout((JComponent) panelEscolha);
			panelEscolha.setLayout(panelLayout);
			panelEscolha.setBackground(new java.awt.Color(208,228,208));
			{
				ComboBoxModel planosDeSaudeModel = new DefaultComboBoxModel(
						planos.toArray());
				planosDeSaude = new JComboBox();
				planosDeSaude.setModel(planosDeSaudeModel);
			}
			{
				porPlano = new JRadioButton();
				porPlano.setText("Plano de Saude especifico:");
				if (planos.isEmpty())
					porPlano.setEnabled(false);
					porPlano.setOpaque(false);
			}
			{
				entreDatas = new JRadioButton();
				entreDatas.setText("Entre datas especificas:");
				entreDatas.setOpaque(false);
			}
			{
				Integer[] dias = new Integer[31];
				for (int i = 1; i <= 31; i++) {
					dias[i - 1] = Integer.valueOf(i);
				}
				ComboBoxModel diaModel = new DefaultComboBoxModel(dias);
				dia = new JComboBox();
				dia.setModel(diaModel);
				ComboBoxModel dia1Model = new DefaultComboBoxModel(dias);
				dia1 = new JComboBox();
				dia1.setModel(dia1Model);
				ComboBoxModel dia2Model = new DefaultComboBoxModel(dias);
				dia2 = new JComboBox();
				dia2.setModel(dia2Model);
			}
			{
				Integer[] meses = new Integer[12];
				for (int i = 1; i <= 12; i++) {
					meses[i - 1] = Integer.valueOf(i);
				}
				ComboBoxModel diaModel = new DefaultComboBoxModel(meses);
				mes = new JComboBox();
				mes.setModel(diaModel);
				ComboBoxModel dia1Model = new DefaultComboBoxModel(meses);
				mes1 = new JComboBox();
				mes1.setModel(dia1Model);
				ComboBoxModel dia2Model = new DefaultComboBoxModel(meses);
				mes2 = new JComboBox();
				mes2.setModel(dia2Model);
			}
			{
				ano = new JTextField();
			}
			{
				dataEspecifica = new JRadioButton();
				dataEspecifica.setText("Data especifica: ");
				dataEspecifica.setOpaque(false);
			}
			{
				getGera().addActionListener(
						(new java.awt.event.ActionListener() {
							@Override
							public void actionPerformed(ActionEvent arg0) {
								if (dataEspecifica.isSelected()) {
									Integer diaUsavel = (Integer) dia
											.getModel().getSelectedItem();
									Integer mesUsavel = (Integer) mes
											.getModel().getSelectedItem()-1;
									try {
										Integer anoUsavel = Integer.valueOf(ano
												.getText());
										data = new GregorianCalendar(anoUsavel, mesUsavel, diaUsavel);
										tabbed.remove(tabbed.indexOfTab("Gerador de Relatórios"));
										panelRelatorio = null;
										tabbed.addTab("Relatório", null, getPanelRelatorio(), null);
									} catch (Exception e) {
										e.printStackTrace();
										JOptionPane.showMessageDialog(escolha,
												 "Data invalida",
												 "Atenção!", JOptionPane.PLAIN_MESSAGE);
									}
									
								} else if (entreDatas.isSelected()) {
									Integer diaInicio = (Integer) dia1
											.getModel().getSelectedItem();
									Integer mesInicio = (Integer) mes1
											.getModel().getSelectedItem()-1;
									Integer diaFinal = (Integer) dia2
											.getModel().getSelectedItem();
									Integer mesFinal = (Integer) mes2
											.getModel().getSelectedItem()-1;
									try {
										Integer anoInicio = Integer
										.valueOf(ano1.getText());
										Integer anoFinal = Integer.valueOf(ano2
												.getText());
										dataInicial = new GregorianCalendar(
												anoInicio, mesInicio, diaInicio);
										dataFinal = new GregorianCalendar(anoFinal,
												mesFinal, diaFinal);
//										tabbed.remove(tabbed.indexOfTab("Gerador de Relatórios"));
										panelRelatorio = null;
										tabbed.addTab("Relatório", null, getPanelRelatorio(), null);
									} catch (Exception e) {
										JOptionPane.showMessageDialog(escolha,
												 "Data invalida",
												 "Atenção!", JOptionPane.PLAIN_MESSAGE);
									}													
								} else if (porPlano.isSelected()) {
									planoEscolhido = (PlanoDeSaude) planosDeSaude.getModel().getSelectedItem();
									tabbed.remove(tabbed.indexOfTab("Gerador de Relatórios"));
									panelRelatorio = null;
									tabbed.addTab("Relatório", null, getPanelRelatorio(), null);
								} else if (getTodasConsultas().isSelected()) {
									try {
										tabbed.remove(tabbed.indexOfTab("Gerador de Relatórios"));
										panelRelatorio = null;
										tabbed.addTab("Relatório", null, getPanelRelatorio(), null);
									} catch (Exception e) {
										e.printStackTrace();
									}
								} else {
									
								 JOptionPane.showMessageDialog(escolha,
								 "Nenhum tipo de Relatório foi Selecionado",
								 "Atenção!", JOptionPane.PLAIN_MESSAGE);
								}
								
							}

						}));
				
				getLimpa().addActionListener(
						(new java.awt.event.ActionListener() {
							@Override
							public void actionPerformed(ActionEvent arg0) {
								ano1.setText("");
								ano.setText("");
								ano2.setText("");
								dia.setSelectedItem(1);
								dia1.setSelectedItem(1);
								dia2.setSelectedItem(1);
								mes.setSelectedItem(1);
								mes1.setSelectedItem(1);
								mes2.setSelectedItem(1);
							}

						}));
				
				getClose().addActionListener(
						(new java.awt.event.ActionListener() {
							@Override
							public void actionPerformed(ActionEvent arg0) {
								tabbed.remove(tabbed.indexOfTab("Gerador de Relatórios"));
								panelEscolha = null;
							}

						}));
			}

			getGrupoBotoes().add(dataEspecifica);
			getGrupoBotoes().add(entreDatas);
			getGrupoBotoes().add(porPlano);
			getGrupoBotoes().add(getTodasConsultas());
			panelLayout.setHorizontalGroup(panelLayout.createSequentialGroup()
				.addContainerGap()
				.addGroup(panelLayout.createParallelGroup()
				    .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				        .addComponent(getTodasConsultas(), GroupLayout.PREFERRED_SIZE, 196, GroupLayout.PREFERRED_SIZE)
				        .addGroup(panelLayout.createParallelGroup()
				            .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				                .addComponent(getJLabel1(), GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				                .addGap(351))
				            .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				                .addComponent(getJLabel4(), GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				                .addGap(351))
				            .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				                .addComponent(getJLabel9(), GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				                .addGap(351))
				            .addComponent(getJSeparator2(), GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 371, GroupLayout.PREFERRED_SIZE))
				        .addGap(60))
				    .addGroup(panelLayout.createSequentialGroup()
				        .addGroup(panelLayout.createParallelGroup()
				            .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				                .addComponent(porPlano, GroupLayout.PREFERRED_SIZE, 221, GroupLayout.PREFERRED_SIZE)
				                .addGap(19)
				                .addGroup(panelLayout.createParallelGroup()
				                    .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				                        .addComponent(planosDeSaude, GroupLayout.PREFERRED_SIZE, 126, GroupLayout.PREFERRED_SIZE)
				                        .addGap(84))
				                    .addGroup(panelLayout.createSequentialGroup()
				                        .addGroup(panelLayout.createParallelGroup()
				                            .addComponent(dia2, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 61, GroupLayout.PREFERRED_SIZE)
				                            .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				                                .addComponent(dia1, GroupLayout.PREFERRED_SIZE, 51, GroupLayout.PREFERRED_SIZE)
				                                .addGap(10))
				                            .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				                                .addComponent(dia, GroupLayout.PREFERRED_SIZE, 51, GroupLayout.PREFERRED_SIZE)
				                                .addGap(10)))
				                        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
				                        .addGroup(panelLayout.createParallelGroup()
				                            .addComponent(getJLabel2(), GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
				                            .addComponent(getJLabel5(), GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE)
				                            .addComponent(getJLabel6(), GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 34, GroupLayout.PREFERRED_SIZE))
				                        .addGroup(panelLayout.createParallelGroup()
				                            .addGroup(panelLayout.createSequentialGroup()
				                                .addGroup(panelLayout.createParallelGroup()
				                                    .addComponent(mes1, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE)
				                                    .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				                                        .addComponent(mes, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
				                                        .addGap(6))
				                                    .addComponent(mes2, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE))
				                                .addGroup(panelLayout.createParallelGroup()
				                                    .addComponent(getJLabel3(), GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
				                                    .addComponent(getJLabel7(), GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE)
				                                    .addComponent(getJLabel8(), GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 44, GroupLayout.PREFERRED_SIZE))
				                                .addGap(9))
				                            .addComponent(getLimpa(), GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 103, GroupLayout.PREFERRED_SIZE)))))
				            .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				                .addComponent(getInformacao(), GroupLayout.PREFERRED_SIZE, 445, GroupLayout.PREFERRED_SIZE)
				                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)))
				        .addGroup(panelLayout.createParallelGroup()
				            .addGroup(panelLayout.createSequentialGroup()
				                .addGroup(panelLayout.createParallelGroup()
				                    .addComponent(getJTextField2(), GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 65, GroupLayout.PREFERRED_SIZE)
				                    .addComponent(getJTextField1(), GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 65, GroupLayout.PREFERRED_SIZE)
				                    .addComponent(ano, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 65, GroupLayout.PREFERRED_SIZE))
				                .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
				                .addGroup(panelLayout.createParallelGroup()
				                    .addComponent(getJLabel10(), GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 94, GroupLayout.PREFERRED_SIZE)
				                    .addComponent(getJLabel11(), GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 94, GroupLayout.PREFERRED_SIZE)))
				            .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				                .addGap(27)
				                .addComponent(getGera(), GroupLayout.PREFERRED_SIZE, 149, GroupLayout.PREFERRED_SIZE))))
				    .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				        .addComponent(getExplicacao(), GroupLayout.PREFERRED_SIZE, 562, GroupLayout.PREFERRED_SIZE)
				        .addGap(65))
				    .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				        .addGroup(panelLayout.createParallelGroup()
				            .addComponent(entreDatas, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 191, GroupLayout.PREFERRED_SIZE)
				            .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createSequentialGroup()
				                .addComponent(dataEspecifica, GroupLayout.PREFERRED_SIZE, 151, GroupLayout.PREFERRED_SIZE)
				                .addGap(40)))
				        .addComponent(getJSeparator1(), GroupLayout.PREFERRED_SIZE, 371, GroupLayout.PREFERRED_SIZE)
				        .addGap(65)))
				.addGap(21)
				.addComponent(getClose(), GroupLayout.PREFERRED_SIZE, 101, GroupLayout.PREFERRED_SIZE)
				.addContainerGap(29, Short.MAX_VALUE));
			panelLayout.setVerticalGroup(panelLayout.createSequentialGroup()
				.addContainerGap(25, 25)
				.addComponent(getInformacao(), GroupLayout.PREFERRED_SIZE, 35, GroupLayout.PREFERRED_SIZE)
				.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
				.addComponent(getExplicacao(), GroupLayout.PREFERRED_SIZE, 56, GroupLayout.PREFERRED_SIZE)
				.addGap(36)
				.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				    .addComponent(ano, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				    .addComponent(getJLabel1(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				    .addComponent(getJLabel3(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				    .addComponent(mes, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
				    .addComponent(getJLabel2(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 13, GroupLayout.PREFERRED_SIZE)
				    .addComponent(dia, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				    .addComponent(dataEspecifica, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 15, GroupLayout.PREFERRED_SIZE))
				.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
				.addComponent(getJSeparator1(), GroupLayout.PREFERRED_SIZE, 8, GroupLayout.PREFERRED_SIZE)
				.addGap(22)
				.addGroup(panelLayout.createParallelGroup()
				    .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				        .addComponent(getJLabel10(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE)
				        .addComponent(getJLabel4(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				        .addComponent(getJTextField1(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				        .addComponent(mes1, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				        .addComponent(dia1, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				        .addComponent(entreDatas, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE))
				    .addGroup(panelLayout.createSequentialGroup()
				        .addGap(7)
				        .addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				            .addComponent(getJLabel7(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				            .addComponent(getJLabel5(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 13, GroupLayout.PREFERRED_SIZE))))
				.addGap(22)
				.addGroup(panelLayout.createParallelGroup()
				    .addGroup(GroupLayout.Alignment.LEADING, panelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				        .addComponent(getJLabel11(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 18, GroupLayout.PREFERRED_SIZE)
				        .addComponent(getJTextField2(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				        .addComponent(mes2, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				        .addComponent(dia2, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
				    .addGroup(panelLayout.createSequentialGroup()
				        .addGap(7)
				        .addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				            .addComponent(getJLabel9(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				            .addComponent(getJLabel8(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				            .addComponent(getJLabel6(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 13, GroupLayout.PREFERRED_SIZE))))
				.addGap(19)
				.addComponent(getJSeparator2(), GroupLayout.PREFERRED_SIZE, 8, GroupLayout.PREFERRED_SIZE)
				.addGap(18)
				.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				    .addComponent(planosDeSaude, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				    .addComponent(porPlano, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE))
				.addGap(31)
				.addComponent(getTodasConsultas(), GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE)
				.addGap(72)
				.addGroup(panelLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
				    .addComponent(getGera(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE)
				    .addComponent(getClose(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE)
				    .addComponent(getLimpa(), GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE))
				.addContainerGap(65, 65));
		}

	}

	public void geraRelatorio() {
		{
			panelRelatorio = new JPanel();
			GroupLayout panelLayout1 = new GroupLayout((JComponent)panelRelatorio);
			panelRelatorio.setLayout(panelLayout1);
			panelRelatorio.setBackground(new java.awt.Color(208,228,208));
			panelLayout1.setHorizontalGroup(panelLayout1.createSequentialGroup()
				.addContainerGap(48, 48)
				.addGroup(panelLayout1.createParallelGroup()
				    .addGroup(panelLayout1.createSequentialGroup()
				        .addComponent(getTitulo(), GroupLayout.PREFERRED_SIZE, 695, GroupLayout.PREFERRED_SIZE))
				    .addGroup(GroupLayout.Alignment.LEADING, panelLayout1.createSequentialGroup()
				        .addGap(19)
				        .addComponent(getTextoRelatorio(), GroupLayout.PREFERRED_SIZE, 482, GroupLayout.PREFERRED_SIZE)
				        .addGap(53)
				        .addComponent(getOk(), GroupLayout.PREFERRED_SIZE, 141, GroupLayout.PREFERRED_SIZE)))
				.addContainerGap(47, Short.MAX_VALUE));
			panelLayout1.setVerticalGroup(panelLayout1.createSequentialGroup()
				.addContainerGap(25, 25)
				.addComponent(getTitulo(), GroupLayout.PREFERRED_SIZE, 62, GroupLayout.PREFERRED_SIZE)
				.addGap(29)
				.addGroup(panelLayout1.createParallelGroup()
				    .addGroup(panelLayout1.createSequentialGroup()
				        .addComponent(getTextoRelatorio(), GroupLayout.PREFERRED_SIZE, 413, GroupLayout.PREFERRED_SIZE))
				    .addGroup(GroupLayout.Alignment.LEADING, panelLayout1.createSequentialGroup()
				        .addGap(383)
				        .addComponent(getOk(), GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)))
				.addContainerGap(41, Short.MAX_VALUE));
		}
		{
			getOk().addActionListener(
					(new java.awt.event.ActionListener() {
						@Override
						public void actionPerformed(ActionEvent arg0) {
							tabbed.remove(tabbed.indexOfTab("Relatório"));
							tabbed.addTab("Gerador de Relatórios", null, getPanelEscolha(), null);
							panelRelatorio = null;
						}

					}));
		}
		try {
			if (dataEspecifica.isSelected()) {
				titulo.setText("Relatório de Lucros por Data Específica");
				textoRelatorio.setText(RelatoriosConsultas.geraRelatorioData(consultas, data));
			} else if (entreDatas.isSelected()) {
				titulo.setText("Relatório de Lucros entre Datas Específicas");
				textoRelatorio.setText(RelatoriosConsultas.geraRelatorioEntreDatas(consultas, dataInicial, dataFinal));
			} else if (porPlano.isSelected()) {
				titulo.setText("Relatório de Lucros de um Plano de Saude Específico\n" + planoEscolhido.getNomeDoPlano());
				List<Consulta> consultasValidas = new ArrayList<Consulta>();
				for (Consulta c : consultas) {
					if (c.getPaciente().getPlanoDeSaude().equals(planoEscolhido))
						consultasValidas.add(c);
				}
				textoRelatorio.setText(RelatoriosConsultas.geraRelatorioEspecifico(consultasValidas));	
			} else if (getTodasConsultas().isSelected()) {
				titulo.setText("Relatório de Lucros Geral");
				textoRelatorio.setText(RelatoriosConsultas.geraRelatorioEspecifico(consultas));
			}
		} catch (Exception e) {
			JOptionPane.showMessageDialog(escolha,
					 e.getMessage(),
					 "Atenção!", JOptionPane.PLAIN_MESSAGE);
		}
		
	}

	private ButtonGroup getGrupoBotoes() {
		if (grupoBotoes == null) {
			grupoBotoes = new ButtonGroup();
		}
		return grupoBotoes;
	}

	private JTextField getJTextField1() {
		if (ano1 == null) {
			ano1 = new JTextField();
		}
		return ano1;
	}

	private JTextField getJTextField2() {
		if (ano2 == null) {
			ano2 = new JTextField();
		}
		return ano2;
	}

	private JLabel getJLabel1() {
		if (jLabel1 == null) {
			jLabel1 = new JLabel();
			jLabel1.setText("Dia");
		}
		return jLabel1;
	}

	private JLabel getJLabel2() {
		if (jLabel2 == null) {
			jLabel2 = new JLabel();
			jLabel2.setText("Mês");
		}
		return jLabel2;
	}

	private JLabel getJLabel3() {
		if (jLabel3 == null) {
			jLabel3 = new JLabel();
			jLabel3.setText("Ano");
		}
		return jLabel3;
	}

	private JLabel getJLabel4() {
		if (jLabel4 == null) {
			jLabel4 = new JLabel();
			jLabel4.setText("Dia");
		}
		return jLabel4;
	}

	private JLabel getJLabel5() {
		if (jLabel5 == null) {
			jLabel5 = new JLabel();
			jLabel5.setText("Mês");
		}
		return jLabel5;
	}

	private JLabel getJLabel6() {
		if (jLabel6 == null) {
			jLabel6 = new JLabel();
			jLabel6.setText("Mês");
		}
		return jLabel6;
	}

	private JLabel getJLabel7() {
		if (jLabel7 == null) {
			jLabel7 = new JLabel();
			jLabel7.setText("Ano");
		}
		return jLabel7;
	}

	private JLabel getJLabel8() {
		if (jLabel8 == null) {
			jLabel8 = new JLabel();
			jLabel8.setText("Ano");
		}
		return jLabel8;
	}

	private JLabel getJLabel9() {
		if (jLabel9 == null) {
			jLabel9 = new JLabel();
			jLabel9.setText("Dia");
		}
		return jLabel9;
	}

	private JSeparator getJSeparator1() {
		if (jSeparator1 == null) {
			jSeparator1 = new JSeparator();
		}
		return jSeparator1;
	}

	private JSeparator getJSeparator2() {
		if (jSeparator2 == null) {
			jSeparator2 = new JSeparator();
		}
		return jSeparator2;
	}

	private JRadioButton getTodasConsultas() {
		if (todasConsultas == null) {
			todasConsultas = new JRadioButton();
			todasConsultas.setText("Todas as Consultas");
			todasConsultas.setOpaque(false);
		}
		return todasConsultas;
	}

	private JLabel getJLabel10() {
		if (jLabel10 == null) {
			jLabel10 = new JLabel();
			jLabel10.setText("(data inicial)");
		}
		return jLabel10;
	}

	private JLabel getJLabel11() {
		if (jLabel11 == null) {
			jLabel11 = new JLabel();
			jLabel11.setText("(data final)");
		}
		return jLabel11;
	}

	private JButton getLimpa() {
		if (limpa == null) {
			limpa = new JButton();
			limpa.setText("Limpar");
			limpa.setBackground(new java.awt.Color(75,95,75));
			limpa.setForeground(new java.awt.Color(144,238,144));
		}
		return limpa;
	}

	private JButton getGera() {
		if (gera == null) {
			gera = new JButton();
			gera.setText("Gerar Relatório");
			gera.setBackground(new java.awt.Color(75,95,75));
			gera.setForeground(new java.awt.Color(144,238,144));
		}
		return gera;
	}

	private JTextArea getTextoRelatorio() {
		if (textoRelatorio == null) {
			textoRelatorio = new JTextArea();
			textoRelatorio.setBorder(BorderFactory.createTitledBorder(""));
			textoRelatorio.setEditable(false);
			textoRelatorio.setOpaque(false);
		}
		return textoRelatorio;
	}

	private JTextArea getTitulo() {
		if (titulo == null) {
			titulo = new JTextArea();
			titulo.setEditable(false);
			titulo.setFont(new java.awt.Font("Purisa", 1, 14));
			titulo.setOpaque(false);
			titulo.setForeground(new java.awt.Color(45,105,45));
		}
		return titulo;
	}
	
	private JTextArea getInformacao() {
		if(informacao == null) {
			informacao = new JTextArea();
			informacao.setText("Gerador de Relatórios de Lucros");
			informacao.setEditable(false);
			informacao.setOpaque(false);
			informacao.setFont(new java.awt.Font("Purisa",1,14));
			informacao.setForeground(new java.awt.Color(56,119,56));
		}
		return informacao;
	}
	
	private JTextArea getExplicacao() {
		if(explicacao == null) {
			explicacao = new JTextArea();
			explicacao.setText("Escolha um tipo de Relatorio para ser gerado.\nInfome os dados pedidos para a opção escolhida e clique em 'Gerar Relatórios'");
			explicacao.setEditable(false);
			explicacao.setOpaque(false);
			explicacao.setForeground(new java.awt.Color(33,105,33));
			explicacao.setFont(new java.awt.Font("Monospaced",0,12));
		}
		return explicacao;
	}
	
	private JButton getOk() {
		if(ok == null) {
			ok = new JButton();
			ok.setText("Fechar");
			ok.setForeground(new java.awt.Color(144,238,144));
			ok.setBackground(new java.awt.Color(75,95,75));
		}
		return ok;
	}
	
	private JButton getClose() {
		if(close == null) {
			close = new JButton();
			close.setText("Fechar");
			close.setBackground(new java.awt.Color(75,95,75));
			close.setForeground(new java.awt.Color(144,238,144));
		}
		return close;
	}
	
	public JPanel getPanelEscolha() {
		if (panelEscolha == null) {
			escolheRelatorio();
		}
		return panelEscolha;
	}
	
	public JPanel getPanelRelatorio() {
		if (panelRelatorio == null) {
			geraRelatorio();
		}
		return panelRelatorio;
	}

}
